#! /usr/bin/python
import sys
from mechanize import Browser
from BeautifulSoup import BeautifulSoup

br = Browser()
for arg in sys.argv[1:]:
    page = br.open("http://walsai.com/oss/ipaste/resources/tinypic.html")
    br.select_form(name="upload_form")
    br.form.add_file(open(arg), filename="image")
    br.submit()
    page = br.follow_link(text="Click here")
    html = page.read()
    soup =  BeautifulSoup(html)
    image = soup.find("input",id="direct-url")
    print arg + " >> "+ image['value']
